package com.one.controller;

import com.one.dto.Result;
import com.one.dto.TjfxIndicator;
import com.one.dto.TjfxScore;
import com.one.entity.EvaluateResultInfoEntity;
import com.one.entity.SemesterInfoEntity;
import com.one.entity.UserRoleEntity;
import com.one.service.SemesterInfoService;
import com.one.service.TjfxService;
import com.one.utils.JsonObject;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <统计分析处理></>
 * @ author:qtl
 * @ date:2021/10/8
 */
@RestController
@RequestMapping("/tJFX")
public class TjcxController {
    private final SemesterInfoService semesterInfoService;
    private final TjfxService tjfxService;

    public TjcxController(SemesterInfoService semesterInfoService, TjfxService tjfxService) {
        this.semesterInfoService = semesterInfoService;
        this.tjfxService = tjfxService;
    }
   /* //查询批次
    @ApiOperation(value = "查询批次", notes = "查询批次")
    @PostMapping("/selectBatch1")
    public Result selectBatch1(@RequestBody(required = false) SemesterInfoEntity semesterInfoEntity){
        return semesterInfoService.selectBatch(semesterInfoEntity);
    }*/
   /* //查询所有用户
    @ApiOperation(value = "查询用户角色", notes = "查询用户角色")
    @RequestMapping("query")
    public @ResponseBody
    JsonObject query(UserRoleEntity userRoler){
        List<UserRoleEntity> list =  tjfxService.query(userRoler);
        //System.out.println(list.size());

        //创建返回对象实例
        //创建返回对象实例
        JsonObject object = new JsonObject();
        object.setCode(0);
        object.setCount(list.size());
        object.setMsg("ok");
        object.setData(list);
      //  System.out.println(object);
        return object;
    }*/
    //查询所有不重复的评价人,
    @ApiOperation(value = "统计评价人", notes = "统计评价人")
    @PostMapping("allTjfx")
    public @ResponseBody
    JsonObject allTjfx(EvaluateResultInfoEntity evaluateResultInfoEntity){
        List<EvaluateResultInfoEntity> list =  tjfxService.allTjfx(evaluateResultInfoEntity);
        //System.out.println(list.size());

        //创建返回对象实例
        //创建返回对象实例
        JsonObject object = new JsonObject();
        object.setCode(0);
        object.setCount(list.size());
        object.setMsg("ok");
        object.setData(list);
       // System.out.println(object);
        return object;
    }

    //查询评教总成绩,根据被评教人的id，查询出被评的条数和总分，算出平均值
    @ApiOperation(value = "查询被评价人的成绩", notes = "查询被评价人的成绩")
    @PostMapping("TjfxScore")
    public @ResponseBody
    JsonObject TjfxScore(TjfxScore tjfxScore){
        List<TjfxScore> list =  tjfxService.TjfxScore(tjfxScore);
        //System.out.println(list.size());
        //创建返回对象实例
        //创建返回对象实例
        JsonObject object = new JsonObject();
        object.setCode(0);
        object.setCount(list.size());
        object.setMsg("ok");
        object.setData(list);
        //System.out.println(object);
        return object;
    }

    //查询指标
    @ApiOperation(value = "统计指标", notes = "统计指标")
    @PostMapping("TjfxIndicator")
    public @ResponseBody
    JsonObject TjfxIndicator(TjfxIndicator tjfxIndicator){
        List<TjfxIndicator> list =  tjfxService.TjfxIndicator(tjfxIndicator);
        //System.out.println(list.size());
        //创建返回对象实例
        //创建返回对象实例
        JsonObject object = new JsonObject();
        object.setCode(0);
        object.setCount(list.size());
        object.setMsg("ok");
        object.setData(list);
        System.out.println(object);
        return object;
    }
  
    

}
